package cn.exempale.mscapplication.emnus;

public enum ResultType {

    SUCCESS(0, "success"),
    ERROR(-1, "error"),
    ;

    private final int code;
    private final String value;

    ResultType(int code, String value) {
        this.code = code;
        this.value = value;
    }

    public int getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public static ResultType match(int code) {
        for (ResultType type : values())
            if (type.code == code)
                return type;
        return ERROR;
    }
}
